package global;

import implementations.PointImpl;
import implementations.ShipImpl;
import interfaces.IPoint;
import interfaces.IShip;

import java.util.ArrayList;

public class GlobalVars {
	public static ArrayList<IShip> ships;
	public static int gridXSize;
	public static int gridYSize;
	public static int maxShipLength;
	
	public static char myShipPart=(char)97;
	public static char myShipPartHitted=(char)98;
	public static char myBoardMiss=(char)95;
	public static char waves=(char)96;
	
	public static char enemyBoardHit='x';
	public static char enemyBoardMiss=(char)96;
	
	public static void init() {
		GlobalVars vars=new GlobalVars();
		maxShipLength=10;
		gridXSize=10;
		gridYSize=20;
		ships = new ArrayList<>();
		ships.add(vars.ship0());
		ships.add(vars.ship1());
		ships.add(vars.ship1());
		ships.add(vars.ship2());
		ships.add(vars.ship2());
		ships.add(vars.ship3());
		//ships.add(vars.ship4());
		//ships.add(vars.ship4());

	}

	private IShip ship0() {
		ArrayList<IPoint> thePoints = new ArrayList<>();
		thePoints.add(new PointImpl(0, 0));
		IShip ship = new ShipImpl(thePoints);
		return ship;
	}

	private IShip ship1() {
		ArrayList<IPoint> thePoints = new ArrayList<>();
		thePoints.add(new PointImpl(0, 0));
		thePoints.add(new PointImpl(1, 0));
		IShip ship = new ShipImpl(thePoints);
		return ship;
	}

	private IShip ship2() {
		ArrayList<IPoint> thePoints = new ArrayList<>();
		thePoints.add(new PointImpl(0, 0));
		thePoints.add(new PointImpl(1, 0));
		thePoints.add(new PointImpl(2, 0));
		thePoints.add(new PointImpl(3, 0));
		IShip ship = new ShipImpl(thePoints);
		return ship;
	}

	private IShip ship3() {
		ArrayList<IPoint> thePoints = new ArrayList<>();
		thePoints.add(new PointImpl(0, 0));
		thePoints.add(new PointImpl(1, 0));
		thePoints.add(new PointImpl(2, 0));
		thePoints.add(new PointImpl(3, 0));
		thePoints.add(new PointImpl(4, 0));
		thePoints.add(new PointImpl(5, 0));
		thePoints.add(new PointImpl(6, 0));
		thePoints.add(new PointImpl(7, 0));

		IShip ship = new ShipImpl(thePoints);
		return ship;
	}

	private IShip ship4() {
		ArrayList<IPoint> thePoints = new ArrayList<>();
		thePoints.add(new PointImpl(0, 0));
		thePoints.add(new PointImpl(1, 0));
		thePoints.add(new PointImpl(2, 0));
		thePoints.add(new PointImpl(3, 0));
		thePoints.add(new PointImpl(4, 0));
		thePoints.add(new PointImpl(5, 0));
		thePoints.add(new PointImpl(2, -1));
		thePoints.add(new PointImpl(3, 1));

		IShip ship = new ShipImpl(thePoints);
		return ship;
	}

}
